package com.stx.friends.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.BeanUtils;

import com.stx.friends.dao.CommentDao;
import com.stx.friends.entity.CommentEntity;
import com.stx.friends.service.CommentService;
import com.stx.friends.vo.CommentVo;

public class CommentServiceImpl implements CommentService {

	private CommentDao dao = null;

	public List<CommentVo> list(CommentVo criteria) {

		List<CommentVo> voList = new ArrayList<CommentVo>();

		List<CommentEntity> entityList = dao.list(criteria);

		for (CommentEntity entity : entityList) {

			CommentVo vo = new CommentVo();

			// 对象属性值拷贝 entity => vo
			BeanUtils.copyProperties(entity, vo);

			voList.add(vo);

		}

		return voList;
	}

	@Override
	public void delComment(String wrxUid) {
		
		dao.delComment(wrxUid);

	}
	@Override
	public void addComment(CommentVo comment) {
		
		dao.addComment(comment);
		
	}

	public void setDao(CommentDao dao) {
		this.dao = dao;
	}

	@Override
	public CommentVo getCommentById(String wrxUid) {
		CommentVo vo=new CommentVo();
		CommentEntity entity=new CommentEntity();
		entity = this.dao.getCommentById(wrxUid);
		BeanUtils.copyProperties(entity, vo);
		return vo;
	}

	@Override
	public void update(CommentVo comment) {
		this.dao.updateComment(comment);
		
	}



}
